home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / audacity / plug-ins / vocoder.ny < prev   
Encoding:
Audacity Nyquits plug-in  |  2010-09-21  |  4.5 KB  |  115 lines

  1. ;nyquist plug-in
  2. ;version 3
  3. ;type process
  4. ;categories "http://lv2plug.in/ns/lv2core#SpectralPlugin"
  5. ;name "Vocoder..."
  6. ;action "Processing Vocoder..."
  7. ;info "by Edgar-RFT and David R. Sky\nReleased under terms of the GNU General Public License version 2\nVocoder only works on unsplit stereo tracks. For best results, the voice\nshould be in the left channel and white noise (from Generate > Noise)\nor some other carrier wave should be in the right channel." 
  8.  
  9. ;control dst "Distance: [1 to 120, default = 20]" real "" 20 1 120
  10. ;control mst "Output choice:" choice "both channels, right only" 0
  11. ;control bands "Number of vocoder bands" int "" 40 10 240
  12. ;control track-vl "Amplitude of original audio [percent]" real "" 100 0 100
  13. ;control noise-vl "Amplitude of white noise [percent]" real "" 0 0 100
  14. ;control radar-vl "Amplitude of Radar Needles [percent]" real "" 0 0 100
  15. ;control radar-f "Frequency of Radar Needles [Hz]" real "" 30 1 100
  16.  
  17. ; vocoder by Edgar-RFT
  18. ; a bit of code added by David R. Sky
  19. ; Released under terms of the GNU Public License version 2
  20. ; http://www.opensource.org/licenses/gpl-license.php
  21.  
  22. ; maybe the code once again has to be changed into _one_ local let-binding
  23. ; if you have lots of nyquist "[gc:" messages try this:
  24. ; (expand 100) ; gives Xlisp more memory but I have noticed no speed difference
  25.  
  26. ; number of octaves between 20hz and 20khz
  27. (setf octaves (/ (log 1000.0) (log 2.0)))
  28.  
  29. ; convert octaves to number of steps (semitones)
  30. (setf steps (* octaves 12.0))
  31.  
  32. ; interval - number of steps per vocoder band
  33. (setf interval (/ steps bands))
  34.  
  35. ; Some useful calculations but not used in this plugin
  36.  
  37. ; half tone distance in linear
  38. ; (print (exp (/ (log 2.0) 12)))
  39.  
  40. ; octave distance in linear
  41. ; (print (exp (/ (log 1000.0) 40)))
  42.  
  43. ; The Radar Wavetable
  44.  
  45. ; make *radar-table* a global variable.
  46. (setf contol-dummy *control-srate*)   ; save old *control-srate*
  47. (set-control-srate *sound-srate*)  
  48. (setf *radar-table* (pwl (/ 1.0 *control-srate*) 1.0  ; 1.0 after 1 sample
  49.                          (/ 2.0 *control-srate*) 0.0  ; 0.0 after 2 samples
  50.                          (/ 1.0 radar-f))) ; stay 0.0 until end of the period
  51. (set-control-srate contol-dummy)      ; restore *control-srate*
  52. ; make *radar-table* become a nyquist wavetable of frequency radar-f
  53. (setf *radar-table* (list *radar-table* (hz-to-step radar-f) T))
  54.  
  55. ; increase the volume of the audacity track in the middle of the slider
  56. ; the sqrt trick is something like an artifical db scaling
  57. (setf track-vol (sqrt (/ track-vl 100.0)))
  58. ; decrease the volume of the white noise in the middle of the slider
  59. ; the expt trick is an inverse db scaling
  60. (setf noise-vol (expt (/ noise-vl 100.0) 2.0))
  61. ; also increase the volume of the needles in the middle of the slider
  62. (setf radar-vol (sqrt (/ radar-vl 100.0)))
  63.  
  64. ; here you can switch the tracks on and off for bug tracking
  65.  
  66. ;  (setf radar-vol 0)
  67. ;  (setf noise-vol 0)
  68. ;  (setf track-vol 0)
  69.  
  70. ; The Mixer
  71.  
  72. ; calculate duration of audacity selection
  73. (setf duration (/ len *sound-srate*))
  74.  
  75. ; if track volume slider is less than 100 percent decrease track volume
  76. (if (< track-vl 100) (setf s (vector (aref s 0) (scale track-vol (aref s 1)))))
  77.  
  78. ; if radar volume slider is more than 0 percent add some radar needles
  79. (if (> radar-vl 0) (setf s (vector (aref s 0) (sim (aref s 1)
  80.   (scale radar-vol (osc (hz-to-step radar-f) duration *radar-table*))))))
  81.  
  82. ; if noise volume slider is more than 0 percent add some white noise
  83. (if (> noise-vl 0) (setf s (vector (aref s 0) (sim (aref s 1)
  84.   (scale noise-vol (noise duration))))))
  85.  
  86. ; The Vocoder
  87.  
  88. (defun vocoder ()
  89.   (let ((p (+ (hz-to-step 20) (/ interval 2.0))) ; midi step of 20 Hz + offset
  90.          f   ; we can leave f initialized to NIL
  91.         (q (/ (sqrt 2.0) (/ octaves bands))) ; explanation still missing
  92.         (result 0)) ; must be initialized to 0 because you cannot sum to NIL
  93.     (dotimes (i bands)
  94.       (setf f (step-to-hz p))
  95.       (setf result (sum result
  96.                    (bandpass2 (mult (lowpass8
  97.             (s-max (bandpass2 (aref s 0) f q)
  98.          (scale -1 (bandpass2 (aref s 0) f q))) (/ f dst))
  99.                    (bandpass2 (aref s 1) f q)) f q)))
  100.       (setf p (+ p interval)))
  101.     result))
  102.  
  103. ; The Program
  104.  
  105. (if (arrayp s) (let ()
  106.   (cond ((= mst 1) (vector (aref s 0) (setf (aref s 1) (vocoder))))
  107.         ((= mst 0) (setf s (vocoder))))
  108.   (cond ((= mst 1) (setq peakamp (peak (aref s 1) ny:all)))
  109.         ((= mst 0) (setq peakamp (peak s ny:all))))
  110.   (cond ((= mst 1) (vector (aref s 0) (setf (aref s 1)
  111.                                         (scale (/ 1.0 peakamp) (aref s 1)))))
  112.         ((= mst 0) (setf s (scale (/ 1.0 peakamp) s))))
  113. s))
  114.  
  115.